﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>方法推送</title>
    <script type="text/javascript">
        //删除.
        function Del(mypk, nodeid) {
            if (mypk == '') {
                alert("默认发送不允许删除，您可以修改。");
                return;
            }
            if (window.confirm('您确定要删除吗?') == false)
                return;
            window.location.href = 'Method.htm?MyPK=' + mypk + '&DoType=Del&FrmID=' + nodeid;
        }
    </script>
    <link href="../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" type="text/javascript" src="../../Comm/JScript.js"></script>
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/PinYin.js" type="text/javascript"> </script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <base target="_self" />
    <script type="text/javascript">
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        /*隐藏与显示.*/
        function ShowHidden(ctrlID) {

            var ctrl = document.getElementById(ctrlID);
            if (ctrl.style.display == "block") {
                ctrl.style.display = 'none';
            } else {
                ctrl.style.display = 'block';
            }
        }
    </script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.
        $(function () {

            var frmID = GetQueryString("FrmID");
            var myPK = GetQueryString("MyPK");

            var ens = new Entities("BP.Sys.MapAttrs");
            ens.Retrieve("FK_MapData", myPK, "Idx");

            for (var i = 0; i < ens.length; i++) {

                var en = ens[i];

                var newRow = "";
                newRow = "<tr ><td class=Idx>" + (i + 1) + "</td>";
                newRow += "<td>" + en.KeyOfEn + "</td>";
                newRow += "<td>" + GenerLab(en) + "</td>"; //生成标签.
                newRow += "<td>" + GetFieldType(en) + "</td>";
                newRow += "<td><img src='../../Img/Btn/Up.gif' onclick=\"Up('" + en.MyPK + "')\" alt='上移' />&nbsp;-&nbsp;<img src='../../Img/Btn/Down.gif' onclick=\"Down('" + en.MyPK + "')\" alt='下移' /> </td>";
                newRow += "<td><a href=\"javascript:Delete('" + en.MyPK + "')\"><img src='../../Img/Btn/Delete.gif' border=0 />删除</a>";
                newRow += "</td>";
                newRow += "</tr>";
                $("#Table1 tr:last").after(newRow);
            }
        });

        function GetFieldType(mapAttr) {

            if (mapAttr.UIContralType == 0) {
                //控件数据类型
                if (mapAttr.MyDataType == "1") {
                    return "TextBox String";
                } else if (mapAttr.MyDataType == "2") {
                    return "TextBox Int";
                } else if (mapAttr.MyDataType == "3") {
                    return "TextBox Float";
                } else if (mapAttr.MyDataType == "4") {
                    return "TextBox Boolean";
                } else if (mapAttr.MyDataType == "5") {
                    return "TextBox Double";
                } else if (mapAttr.MyDataType == "6") {
                    return "TextBox Date";
                } else if (mapAttr.MyDataType == "7") {
                    return "TextBox DateTime";
                } else if (mapAttr.MyDataType == "8") {
                    return "TextBox Money";
                }
            } else if (mapAttr.UIContralType == 1) {
                //枚举下拉框
                if (mapAttr.LGType == 1) {
                    return "DropDownList Enum";
                } //外键下拉框
                else if (mapAttr.LGType == 2) {
                    return "DropDownList Table";
                }
                //外部数据源
                else if (mapAttr.LGType == 0) {
                    return "DropDownList Table";
                }
            } else if (mapAttr.UIContralType == 2) {//复选框
                return "TextBox Boolean";
            } else if (mapAttr.UIContralType == 3) {//单选妞
                return;
            } else if (mapAttr.UIContralType == 8) {//签字版
                return "Hand Siganture";
            }
            return "未知类型";
        }

        function GenerLab(attr) {

            if (attr.LGType == 0 && attr.UIContralType == 1) {
                return "<a href=\"javascript:EditTableSQL('" + attr.MyPK + "','" + attr.KeyOfEn + "');\" > " + attr.Name + "</a>";
            }

            if (attr.LGType == 0) {
                return "<a href=\"javascript:Edit('" + attr.MyPK + "','" + attr.MyDataType + "','" + attr.GroupID + "','" + attr.LGType + "');\" > " + attr.Name + "</a>";
            }

            if (attr.LGType == 1)
                return "<a href=\"javascript:EditEnum('" + attr.FK_MapData + "','" + attr.MyPK + "','" + attr.KeyOfEn + "');\" > " + attr.Name + "</a>";

            if (attr.LGType == 2)
                return "<a href=\"javascript:EditTable('" + attr.FK_MapData + "','" + attr.MyPK + "','" + attr.KeyOfEn + "');\" > " + attr.Name + "</a>";
        }

        function Edit(mypk, ftype, gf, fk_mapdtl) {

            var url = 'EditF.htm?DoType=Edit&MyPK=' + mypk + '&FType=' + ftype + '&FK_MapData=' + GetQueryString("FrmID") + '&GroupField=' + gf;
            var title = '';
            if (ftype == 1) {
                title = '字段String属性';
                url = '../../Comm/EnOnly.htm?EnName=BP.Sys.FrmUI.MapAttrString&PKVal=' + mypk + '&s=' + Math.random();
            }

            if (ftype == 2 || ftype == 3 || ftype == 5 || ftype == 8) {
                title = '字段Num属性';
                url = '../../Comm/EnOnly.htm?EnName=BP.Sys.FrmUI.MapAttrNum&PKVal=' + mypk + '&s=' + Math.random();
            }

            if (ftype == 6 || ftype == 7) {
                title = '字段 date 属性';

                url = '../../Comm/EnOnly.htm?EnName=BP.Sys.FrmUI.MapAttrDT&PKVal=' + mypk + '&s=' + Math.random();
            }

            if (ftype == 6 || ftype == 7) {
                title = '字段 datetime 属性';

                url = '../../Comm/EnOnly.htm?EnName=BP.Sys.FrmUI.MapAttrDT&PKVal=' + mypk + '&s=' + Math.random();
            }

            if (ftype == 4) {
                title = '字段 boolen 属性';
                url = '../../Comm/EnOnly.htm?EnName=BP.Sys.FrmUI.MapAttrBoolen&PKVal=' + mypk + '&s=' + Math.random();
            }

            OpenEasyUiDialog(url, "eudlgframe", title, 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });

            // OpenEasyUiDialog(url, "dd", title, 730, 500);
            return;
        }

        function EditEnum(fk_mapdata, mypk, keyOfEn) {

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrEnum&PKVal=' + mypk + '&s=' + Math.random();

            OpenEasyUiDialog(url, "eudlgframe", '枚举' + keyOfEn + '属性', 730, 500, "icon-property", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }

        function EditTableSQL(mypk, keyOfEn) {

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrSFSQL&PKVal=' + mypk + '&s=' + Math.random();

            OpenEasyUiDialog(url, "eudlgframe", '外键SQL字段:' + keyOfEn + '属性', 730, 500, "icon-property", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }

        function EditTable(fk_mapData, mypk, keyOfEn) {

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrSFTable&PKVal=' + mypk + '&s=' + Math.random();

            OpenEasyUiDialog(url, "eudlgframe", '外键字段:' + keyOfEn + '属性', 730, 500, "icon-property", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }
        // 向上移动.
        function Up(mypk, idx, t) {

            var en = new Entity("BP.Sys.MapAttr", mypk);
            var data = en.DoMethodReturnString("DoUp");
            if (data.indexOf('err@') != -1)
                alert(data);
            window.location.href = window.location.href;
        }

        //向下移动.
        function Down(mypk, idx, t) {

            var en = new Entity("BP.Sys.MapAttr", mypk);
            var data = en.DoMethodReturnString("DoDown");
            if (data.indexOf('err@') != -1)
                alert(data);
            window.location.href = window.location.href;
        }


        function Help() {
            var url = "http://ccbpm.mydoc.io";
            window.open(url);
        }
        function NewPara() {
            var url = "../../Admin/FoolFormDesigner/FieldTypeList.htm?DoType=AddF&FK_MapData=" + GetQueryString("MyPK");
            OpenEasyUiDialog(url, "eudlgframe", "新建参数", 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }
        //删除.
        function Delete(myPK) {
            if (window.confirm('您确定要删除吗？') == false)
                return;
            var en = new Entity("BP.Sys.MapAttr");
            en.MyPK = myPK;
            en.Delete();
            window.location.href = window.location.href;
        }
        function ToMethodDoc() {
            window.location.href = "MethodDoc.htm?MyPK=" + GetQueryString("MyPK");
        }
    </script>
</head>
<body onkeypress="Esc();" style="font-size: smaller">
    <table id="Table1" style="width: 100%">
        <caption>
            <a href="javascript:ToMethodDoc()">定义方法执行内容</a> - 定义执行方法的参数
        </caption>
        <tr>
            <th>
                序
            </th>
            <th>
                ID
            </th>
            <th>
                名称
            </th>
            <th>
                类型
            </th>
            <th>
                显示顺序
            </th>
            <th>
                操作
            </th>
        </tr>
    </table>
    <fieldset style="border: 0px;">
        <input type="button" value="我需要帮助" onclick="Help()" />
        <input type="button" value="+新建参数" id="Btn_Save" onclick="NewPara()" />&nbsp;&nbsp;
    </fieldset>
</body>
</html>
